{% extends 'TopxiaAdminBundle::layout.html.twig' %}

{% set script_controller = 'user/approved' %}

{% set menu = 'admin_approval_approvals' %}

{% block main %}
  <div class="btn-group">
    <a type="button" class="btn btn-default btn-sm {% if approvalStatus == 'approving' %}btn-primary{% endif %}"
       href="{{ path('admin_approval_approvals',{approvalStatus: 'approving'}) }}">{{ '审核中'|trans }}</a>
    <a type="button" class="btn btn-default btn-sm {% if approvalStatus == 'approved' %}btn-primary{% endif %}"
       href="{{ path('admin_approval_approvals',{approvalStatus: 'approved'}) }}">{{ '审核成功'|trans }}</a>
  </div>
  <form id="user-search-form" class="form-inline well well-sm mtl" action="" method="get" novalidate>
   {% include 'OrgBundle:Org:org-tree-select.html.twig' with {orgCode: app.request.get('orgCode'), modal: 'list'} %}
  
    <div class="form-group">
      <select class="form-control" name="keywordType">
        {{ select_options({'':'--查询条件--'|trans,nickname:'用户名'|trans,email:'邮箱'|trans,truename:'真实姓名'|trans,idcard:'身份证号码'|trans}, app.request.get('keywordType')) }}
      </select>
    </div>
    <div class="form-group">
      <input type="text" id="keyword" name="keyword" class="form-control" value="{{ app.request.query.get('keyword') }}"
             placeholder="{{ '关键词'|trans }}">
    </div>
    <div class="form-group">
      {{ '申请时间:'|trans }}
      <input class="form-control" type="text" id="startDate" name="startDateTime"
             value="{{ app.request.query.get('startDateTime') }}" placeholder="{{ '起始时间'|trans }}">
      -
      <input class="form-control" type="text" id="endDate" name="endDateTime"
             value="{{ app.request.query.get('endDateTime') }}" placeholder="{{ '结束时间'|trans }}">
    </div>
    <button class="btn btn-primary">{{ '搜索'|trans }}</button>
  </form>

  {% if users %}
    <table id="user-table" class="table table-striped">
      <thead>
      <tr>
        <th>ID</th>
        <th>{{ '用户名'|trans }}</th>
        {% include 'OrgBundle:Org/Parts:table-thead-tr.html.twig' %}
        <th>{{ '真实姓名'|trans }}</th>
        <th>{{ '身份证号码'|trans }}</th>
        <th>{{ '邮件'|trans }}</th>
        <th>{{ '申请时间'|trans }}</th>
        <th>{{ '操作'|trans }}</th>
      </tr>
      </thead>
      <tbody>
      {% for user in users %}
        <tr id="user-table-tr-{{ user.id }}">
          <td>{{ user.id }}</td>
          <td><strong>{{ admin_macro.user_link(user) }}</strong></td>
          {% include 'OrgBundle:Org/Parts:table-body-td.html.twig' with {orgCode: user.orgCode}%}
          <td>{{ userProfiles[user.id].truename }}</td>
          <td>{{ userProfiles[user.id].idcard }}</td>
          <td>{{ user.email }}</td>
          <td>{{ user.approvalTime | date('Y-m-d H:i') }}</td>
          <td>
            {% if approvalStatus == 'approved' %}
              <div class="btn-group">
                <a href="#modal" data-toggle="modal" data-url="{{ path('admin_approval_info_view', {id:user.id}) }}"
                   class="btn btn-default btn-sm">{{ '查看'|trans }}</a>
                {% include 'PermissionBundle:Templates:group-button.html.twig' with {parentCode: 'admin_approval_approvals', group:'groupButton', user: user} %}
              </div>
            {% elseif approvalStatus == 'approving' %}
              <a href="#modal" data-toggle="modal" data-url="{{ path('admin_approval_approve', {id:user.id}) }}"
                 class="btn btn-default btn-sm">{{ '审核'|trans }}</a>
            {% endif %}
          </td>
        </tr>
      {% endfor %}
      </tbody>
    </table>

    {{ admin_macro.paginator(paginator) }}
  {% else %}
    {% if approvalStatus == 'approved' %}
      <div class="empty">{{ '暂无已经审核成功的实名认证用户'|trans }}</div>
    {% elseif approvalStatus == 'approving' %}
      <div class="empty">{{ '暂无需要审核中的实名认证用户'|trans }}</div>
    {% endif %}
  {% endif %}

{% endblock %}
